using System;
using System.Collections.Generic;
using System.Text;

namespace SBPweb.Logging
{
    /// <summary>
    /// This class provides region based keyword set definition by using instances of it in conjunction with using"/> keyword.
    /// </summary>
    public class Keyword : IDisposable
    {
        private ICollection<String> mKeywords;

        /// <summary>
        /// Defines a new keyword.
        /// </summary>
        /// <param name="Keyword">Keyword to define.</param>
        public Keyword(String Keyword)
        {
            mKeywords = new String[] { Keyword };

            LogManager.AddKeywords(mKeywords);
        }

        /// <summary>
        /// Defines a new set ow keywords.
        /// </summary>
        /// <param name="Keywords">Set of keywords to define.</param>
        /// <exception cref="System.ArgumentNullException">The "Keywords" param was null.</exception>
        public Keyword(ICollection<String> Keywords)
        {
            if (Keywords == null)
                throw new ArgumentNullException("Keywords");

            mKeywords = Keywords;

            LogManager.AddKeywords(mKeywords);
        }

        #region IDisposable Members

        /// <summary>
        /// Disposes a set of keywords.
        /// </summary>
        public void Dispose()
        {
            LogManager.RemoveKeywords(mKeywords);
        }

        #endregion
    }
}
